<?php
/**
 * 后台订单表操作模型
 * @author lifw
 */
class MWxPay extends MY_Model {
	protected $table = 'wx_pay';

    public function getList($limit){
        $this->db->select( 'w.*,u.avatar,u.nick_name');
        $this->db->distinct();
        $this->db->from($this->table.' w');
        $this->db->join('user u','w.user_id = u.id','INNER');
        $this->db->limit($limit['limit'],$limit['offset']);
        $this->formfilter->doFilter();
        $query = $this->db->get();
        return $query->result();
    }

    public function getCount(){
        $this->db->select('count(distinct w.id) as num');
        $this->db->from($this->table.' w');
        $this->db->join('user u','w.user_id = u.id','INNER');
        $this->formfilter->doFilter();
        $tmp = $this->db->get()->result();
        return (int)$tmp[0]->num;
    }

    public function getById($id)
    {
        $query = $this->db->where('id', $id)->get($this->table);
        return $query->row();
    }
}
